$(function() {
    tableToGridBetter(".result-table", {sortable: false, height: 'auto', width: 'auto'});
    if (useFormat == 'tabs') {
        $("#result-tabs").tabs();
    }
    
    $('.table-link').click(function() {
        var pos = editor.cursorPosition();
        editor.insertIntoLine(pos.line, pos.character, $(this).attr('name'));
    });
    /*
    $('#show-schema').toggle(function() {
        $('#table-list').show();
    }, function() {
        $('#table-list').hide();
    });
    */
    
    var editor = CodeMirror.fromTextArea('sql-console', {
        parserfile: "../contrib/sql/js/parsesql.js",
        stylesheet: "/CodeMirror-0.67/contrib/sql/css/sqlcolors.css",
        path: "/codemirror/js/",
        textWrapping: false,
        height: '150px',
        initCallback: function(editor) {
            editor.grabKeys(function (e) {
                console.log(e);
            }, function(e) {
                console.log('x', e);
                return false;
            });
        }
    });
    
    //console.log(editor);
    /*editor.initCallback = function() {
        alert(1);
        editor.grabKeys(function (e) {
            console.log(e);
        });
    };*/
});

